package com.ad.pet.common.data.http.glide;

import android.content.Context;

import com.bumptech.glide.Glide;
import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.load.engine.cache.InternalCacheDiskCacheFactory;
import com.bumptech.glide.load.model.GlideUrl;
import com.bumptech.glide.module.GlideModule;
import com.ad.pet.App;
import com.ad.pet.common.data.utils.glide.OkHttpUrlLoader;

import java.io.InputStream;

/**
 * Created by z on.
 * Des:
 * Date: 2017/4/6
 */

public class GlideCacheModule implements GlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        int size = 300 * 1024 * 1024;
        String fileName = "rabbos_app";
        builder.setDiskCache(new InternalCacheDiskCacheFactory(context, fileName, size));//setDecodeFormat(DecodeFormat.PREFER_ARGB_8888)


    }

    @Override
    public void registerComponents(Context context, Glide glide) {
        glide.register(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(App
                .getApp().getApplicationComponent().getOkHttpClient()));
    }
}
